home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / dev / lang / amigatalk.lha / intuition / IFFConstants.st < prev    next >
Text File  |  2002-01-26  |  9KB  |  215 lines

  1. " ------------------------------------------------------------------- "
  2. " IFFConstants Class is a Singleton class that allows the user        "
  3. " to reference IFF flags, tags, etc, which are used to process IFF    "
  4. " files. "
  5. ""
  6. " The User does NOT need to create one of these, since DataTypeSystem "
  7. " Class will instantiate the only needed instance of this Class.  See "
  8. " the DataTypeSystem.st source file for the method(s) that help the   "
  9. " User with this Class.                                               "
  10. ""
  11. " ALL singleton classes MUST contain the following:                   "
  12. ""
  13. "   the methods:  isSingleton AND privateSetup     AND                "
  14. "                 uniqueInstance Class instance variable.             "
  15. " ------------------------------------------------------------------- "
  16.  
  17. Class IFFConstants :Dictionary ! uniqueInstance !
  18. [
  19.    isSingleton
  20.      ^ true  
  21. |  
  22.    privateNew ! newinstance !
  23.      newinstance <- super new.
  24.  
  25.      ^ newinstance
  26. |
  27.    new
  28.      ^ self privateSetup
  29. |
  30.    privateSetup
  31.      (uniqueInstance isNil)
  32.        ifTrue: [uniqueInstance <- self privateNew.
  33.  
  34.                 self privateInitializeDictionary.
  35.                ].
  36.                
  37.      ^ self
  38. |
  39.    privateInitializeDictionary
  40.      " Since more entries might be added, this stuff is NOT in a Block."
  41.  
  42.      " bit definitions for 'iff_Flags' field: "
  43.  
  44.      self at: #IFFF_READ     put: 0. " read mode - default "
  45.      self at: #IFFF_WRITE    put: 1. " write mode          "
  46.      self at: #IFFF_RWBITS   put: 1. " (IFFF_READ | IFFF_WRITE) read/write bits "
  47.      self at: #IFFF_FSEEK    put: 2. " forward seek only   "
  48.      self at: #IFFF_RSEEK    put: 4. " random seek         "
  49.  
  50.      self at: #IFFF_RESERVED put: 16rFFFF0000. " Don't touch these bits "
  51.  
  52.      " IFF return codes. Most functions return either zero for success or
  53.      * one of these codes. The exceptions are the read/write functions which
  54.      * return positive values for number of bytes or records read or written,
  55.      * or a negative error code. Some of these codes are not errors per se,
  56.      * but valid conditions such as EOF or EOC (End of Chunk).  There is a 
  57.      * method in IFF class that will translate these numbers into a human-
  58.      * readable (not necessarily understandable) string.  These are here for
  59.      * reference only & you probably won't ever use them in your code.
  60.      "
  61.      self at: #IFFERR_EOF        put: -1.  " Reached logical end of file  "
  62.      self at: #IFFERR_EOC        put: -2.  " About to leave context       "
  63.      self at: #IFFERR_NOSCOPE    put: -3.  " No valid scope for property  "
  64.      self at: #IFFERR_NOMEM      put: -4.  " Internal memory alloc failed "
  65.      self at: #IFFERR_READ       put: -5.  " Stream read error            "
  66.      self at: #IFFERR_WRITE      put: -6.  " Stream write error           "
  67.      self at: #IFFERR_SEEK       put: -7.  " Stream seek error            "
  68.      self at: #IFFERR_MANGLED    put: -8.  " Data in file is corrupt      "
  69.      self at: #IFFERR_SYNTAX     put: -9.  " IFF syntax error             "
  70.      self at: #IFFERR_NOTIFF     put: -10. " Not an IFF file              "
  71.      self at: #IFFERR_NOHOOK     put: -11. " No call-back hook provided   "
  72.      self at: #IFF_RETURN2CLIENT put: -12. " Client handler normal return "
  73.  
  74.      " Control modes for parseIFF method: "
  75.      self at: #IFFPARSE_SCAN     put: 0.
  76.      self at: #IFFPARSE_STEP     put: 1.
  77.      self at: #IFFPARSE_RAWSTEP  put: 2.
  78.  
  79.      " Control modes for storeLocalItem method: "
  80.      self at: #IFFSLI_ROOT       put: 1. " Store in default context      "
  81.      self at: #IFFSLI_TOP        put: 2. " Store in current context      "
  82.      self at: #IFFSLI_PROP       put: 3. " Store in topmost FORM or LIST "
  83.  
  84.  
  85.      " Magic value for writing functions.  If you pass this value in as a size
  86.      * to pushChunk: when writing a file, the parser will figure out the
  87.      * size of the chunk for you.  If you know the size, is it better to
  88.      * provide as it makes things faster.
  89.      "
  90.      self at: #IFFSIZE_UNKNOWN   put: -1.
  91.  
  92.      " Possible call-back command values "
  93.      self at: #IFFCMD_INIT       put: 0. " Prepare the stream for a session "
  94.      self at: #IFFCMD_CLEANUP    put: 1. " Terminate stream session         "
  95.      self at: #IFFCMD_READ       put: 2. " Read bytes from stream           "
  96.      self at: #IFFCMD_WRITE      put: 3. " Write bytes to stream            "
  97.      self at: #IFFCMD_SEEK       put: 4. " Seek on stream                   "
  98.      self at: #IFFCMD_ENTRY      put: 5. " You just entered a new context   "
  99.      self at: #IFFCMD_EXIT       put: 6. " You're about to leave a context  "
  100.      self at: #IFFCMD_PURGELCI   put: 7. " Purge a LocalContextItem         "
  101. ]
  102.  
  103. " ------------------------------------------------------------------- "
  104. " IDNumbers Class is a Singleton class that allows the user           "
  105. " to reference IDNumbers which denote IFF Chunk headers.              "
  106. ""
  107. " The User does NOT need to create one of these, since DataTypeSystem "
  108. " Class will instantiate the only needed instance of this Class.  See "
  109. " the DataTypeSystem.st source file for the method(s) that help the   "
  110. " User with this Class.                                               "
  111. ""
  112. " ALL singleton classes MUST contain the following:                   "
  113. ""
  114. "   the methods:  isSingleton AND privateSetup     AND                "
  115. "                 uniqueInstance Class instance variable.             "
  116. " ------------------------------------------------------------------- "
  117.  
  118. Class IDNumbers :Dictionary ! uniqueInstance !
  119. [
  120.    isSingleton
  121.      ^ true  
  122. |  
  123.    privateNew ! newinstance !
  124.      newinstance <- super new.
  125.  
  126.      ^ newinstance
  127. |
  128.    new
  129.      ^ self privateSetup
  130. |
  131.    privateSetup
  132.      (uniqueInstance isNil)
  133.        ifTrue: [uniqueInstance <- self privateNew.
  134.  
  135.                 self privateInitializeDictionary.
  136.                ].
  137.                
  138.      ^ self
  139. |
  140.    privateInitializeDictionary
  141.      " Since more entries might be added, this stuff is NOT in a Block."
  142.      
  143.      "Used by multiple types:"
  144.      self at: #ID_BODY        put: 16r424F4459. "BODY"
  145.  
  146.      "Animation IDs:"
  147.      self at: #ID_ANIM        put: 16r414E494D. "ANIM"
  148.      self at: #ID_ANHD        put: 16r414E4844. "ANHD"
  149.      self at: #ID_DLTA        put: 16r444C5441. "DLTA"
  150.  
  151.      "DataType IDs:"
  152.      self at: #ID_DTYP        put: 16r44545950. "DTYP"
  153.      self at: #ID_DTHD        put: 16r44544844. "DTHD"
  154.  
  155.      "System file, such as; directory, executable, library,
  156.      * device, font, etc.
  157.      "
  158.      self at: #GID_SYSTEM     put: 16r73797374. "syst"
  159.  
  160.      "Formatted or unformatted text:"
  161.      self at: #GID_TEXT       put: 16r74657874. "text"
  162.  
  163.      "Formatted text with graphics or other DataTypes:"
  164.      self at: #GID_DOCUMENT   put: 16r646F6375. "docu"
  165.  
  166.      "Sound:"
  167.      self at: #GID_SOUND      put: 16r736F756E. "soun"
  168.  
  169.      "Musical instruments used for musical scores:"
  170.      self at: #GID_INSTRUMENT put: 16r696E7374. "inst"
  171.  
  172.      "Musical score:"
  173.      self at: #GID_MUSIC      put: 16r6D757369. "musi"
  174.  
  175.      "Still picture:"
  176.      self at: #GID_PICTURE    put: 16r70696374. "pict"
  177.  
  178.      "Animated picture:"
  179.      self at: #GID_ANIMATION  put: 16r616E696D. "anim"
  180.  
  181.      "Animation with audio track:"
  182.      self at: #GID_MOVIE      put: 16r6D6F7669. "movi"
  183.  
  184.      "A code chunk contains an embedded executable that
  185.      * can be loaded with InternalLoadSeg:
  186.      "
  187.      self at: #ID_CODE        put: 16r44544344. "DTCD"
  188.      self at: #ID_TOOL        put: 16r4454544C. "DTTL"
  189.      self at: #ID_TAGS        put: 16r44545447. "DTTG"
  190.      self at: #ID_NAME        put: 16r4E414D45. "NAME"
  191.  
  192.      "For Picture DataTypes:"
  193.      "IFF types that may be in pictures:"
  194.      self at: #ID_ILBM        put: 16r494C424D. "ILBM"
  195.      self at: #ID_BMHD        put: 16r424D4844. "BMHD"
  196.      self at: #ID_CMAP        put: 16r434D4150. "CMAP"
  197.      self at: #ID_CRNG        put: 16r43524E47. "CRNG"
  198.      self at: #ID_GRAB        put: 16r47524142. "GRAB"
  199.      self at: #ID_SPRT        put: 16r53505254. "SPRT"
  200.      self at: #ID_DEST        put: 16r44455354. "DEST"
  201.      self at: #ID_CAMG        put: 16r43414D47. "CAMG"
  202.  
  203.      "For Text datatypes:"
  204.      "IFF types that may be text:"
  205.      self at: #ID_FTXT        put: 16r46545854. "FTXT"
  206.      self at: #ID_CHRS        put: 16r43485253. "CHRS"
  207.  
  208.      "For Sound DataTypes:"               
  209.      self at: #ID_8SVX        put: 16r38535658. "8SVX"
  210.      self at: #ID_VHDR        put: 16r56484452. "VHDR"
  211.      self at: #ID_CHAN        put: 16r4348414E. "CHAN"
  212.      self at: #ID_SMUS        put: 16r534D5553. "SMUS"
  213. ]
  214.  
  215.